<template>
  <div class="fundodoo-center fundodoo-switch">
    <el-switch
      v-model="status"
      :disabled="true"
      inactive-color="#ff4949"
      active-text="上架"
      inactive-text="下架"
      @click.native="changeStatus"
    />
  </div>
</template>

<script>
import { changeGoodsShowp } from '@/api/goods'

export default {
  name: 'GoodsStatus',
  components: {

  },
  props: {
    gid: {
      type: String,
      required: true
    },
    gs: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      id: -1,
      status: false
    }
  },
  created() {

  },
  mounted() {
    this.id = this.gid
    this.status = this.gs
  },
  beforeMount() {

  },
  methods: {
    changeStatus() {
      const id = this.id
      const status = !this.status
      changeGoodsShowp(id, status).then(res => {
        this.status = status
        this.$emit('statusChange', status)
      })
    }
  }
}

</script>
<style scoped>

</style>
